<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="../../../inc/conn.asp"-->
<!--#include file="../../../inc/function.asp"-->
<%const link="auctions"

search=checkstr(inHTML(request.QueryString("search")))
searchkey=checkstr(inHTML(request.QueryString("searchkey")))
style=checkstr(inHTML(request.QueryString("style")))
aucminprice=checkstr(inHTML(request.QueryString("aucminprice")))
aucmaxprice=checkstr(inHTML(request.QueryString("aucmaxprice")))
store=checkstr(inHTML(request.QueryString("store")))
item_status=checkstr(inHTML(request.QueryString("item_status")))
buynow=checkstr(inHTML(request.QueryString("buynow")))
freeshipping=checkstr(inHTML(request.QueryString("freeshipping")))
sort=checkstr(inHTML(request.QueryString("sort")))
order=checkstr(inHTML(request.QueryString("order")))
typeid=checkstr(inHTML(request.QueryString("typeid")))
CurrentPage=checkstr(inHTML(request.QueryString("page")))
if CurrentPage="" then CurrentPage=1
if isnumeric(CurrentPage)=false then CurrentPage=1


if searchkey="" then
response.Write "<meta http-equiv=""Content-Type"" content=""text/html; charset=utf-8"" />"
response.write"<script>alert('请输入关键字');</script>"
response.write"<script>window.history.back(-1);</script>"
response.end
end if


if typeid<>"" then 
  set rs=server.CreateObject("adodb.recordset")
  sql="select * from auctions where CategoryId='"&typeid&"'"
  rs.open sql,conn,1,1
  if rs.eof and rs.bof then
  response.Write("<script>window.location.href='/';</script>")
  response.End
  else
  id=rs("id")
  CategoryId=rs("CategoryId")
  fid=rs("fid")
  title=rs("title")
  end if
  rs.close
  set rs=nothing

  '读取路径
  typelink_id=id
  For s=1 to 6
	  set rss=conn.execute("select fid,id,title,CategoryId from auctions where id="&typelink_id&"")
	  if not rss.eof then
		 typelink_id=rss("fid")
		 typelink=" > <a href='/auctions/"&rss("CategoryId")&"?s=t'>"&rss("title")&"</a>"+typelink
	  set rss=nothing
	  end if
  Next
  
  sqlsearch=sqlsearch+"&category="&urlid&""
end if


if searchkey<>"" and search="中文搜索" then
  set rsx=server.createobject("adodb.recordset")
  sql="select * from [key] where title='"&searchkey&"'"
  rsx.open sql,conn,1,3
  if not rsx.eof then
	keywordname=rsx("jptitle")
	keyid=rsx("id")
	rsx("hits")=rsx("hits")+1
  rsx.update
  rsx.close
  set rsx=nothing
  else
  rsx.addnew
	url="http://translate.google.cn/translate_t?langpair=zh|ja&hl=ja&ie=utf-8&text="&server.urlencode(searchkey)&""
	wstr=getHTTPPage(url) 
	start=Newstring(wstr,"TRANSLATED_TEXT='") 
	body=Mid(wstr,start+17) 
	body=split(body,"';INPUT_TOOL_PATH=")
	for i=0 to ubound(body)
	keywordname=body(0)
	next
  rsx("title")=searchkey
  rsx("jptitle")=keywordname
  rsx("ip")=ip
  rsx.update
  temp = rsx.bookmark 
  rsx.bookmark = temp 
  keyid=rsx("ID") 
  rsx.close
  set rsx=nothing
  end if
  
  sqlsearch=sqlsearch+"&query="&server.urlencode(keywordname)&""
elseif searchkey<>"" and search="日文搜索" then
  sqlsearch=sqlsearch+"&query="&server.urlencode(searchkey)&""
end if



'读取产品
Set myCache = new Cache
myCache.name="auctionsSearch"&CategoryId&aucminprice&aucmaxprice&store&item_status&buynow&freeshipping&sort&order&CurrentPage&searchkey&search '定义缓存名称 
if myCache.valid then '如果缓存有效
	REST_RESPONSE_AuctionsProduct=myCache.value '读取缓存内容
else
	'价格筛选
	if aucminprice<>"" and aucmaxprice<>"" then
	  if isnumeric(aucminprice)=false then aucminprice=0
	  if isnumeric(aucmaxprice)=false then aucmaxprice=0
	  if cdbl(aucminprice)>cdbl(aucmaxprice) then
	  response.write"<script>alert('筛选价格输入错误');</script>"
	  response.write"<script>window.history.back(-1);</script>"
	  response.end
	  end if
	  sqlsearch=sqlsearch+"&aucminprice="&aucminprice&"&aucmaxprice="&aucmaxprice&""
	end if
	'卖家类型
	if store<>"" then
	  if isnumeric(store)=false then store=0
	  sqlsearch=sqlsearch+"&store="&store&""
	end if
	'商品
	if item_status<>"" then
	  if isnumeric(item_status)=false then item_status=0
	  sqlsearch=sqlsearch+"&item_status="&item_status&""
	end if
	'一口价
	if buynow<>"" then
	  if isnumeric(buynow)=false then buynow=1
	  sqlsearch=sqlsearch+"&buynow="&buynow&""
	end if
	'免日本运费
	if freeshipping<>"" then
	  if isnumeric(freeshipping)=false then freeshipping=1
	  sqlsearch=sqlsearch+"&freeshipping="&freeshipping&""
	end if
	'排序
	if sort<>"" and order<>"" then
	  sqlsearch=sqlsearch+"&sort="&sort&"&order="&order&""
	end if
	
	topurl="http://auctions.yahooapis.jp/AuctionWebService/V2/search?"'正式接口
	postdatastr="appid="&yahoo_daigou_apiid&""&sqlsearch&"&page="&CurrentPage&""
	REST_RESPONSE_AuctionsProduct=getHTTPPage(topurl&postdatastr) 
myCache.add REST_RESPONSE_AuctionsProduct,dateadd("n",1440*web_cache,now) '将内容赋值给缓存，并设置缓存有效期是当前时间＋1000分钟 
end if
myCache.makeEmpty()  
set clsCache=nothing '释放对象



	Set xml=Server.CreateObject("Microsoft.XMLDOM")
	xml.Async=False 
	xml.ValidateOnParse=False 
	xml.LoadXml(REST_RESPONSE_AuctionsProduct) 

	Set item = xml.selectNodes("ResultSet")
	For i = 0 To iLength
	Set oXMLItem = item.item(i)
	totalResultsAvailable=oXMLItem.getAttribute("totalResultsAvailable")
	totalResultsReturned=oXMLItem.getAttribute("totalResultsReturned")
	Next
	Pager_PageCount=int((totalResultsAvailable/20)+0.99999)
	if Pager_PageCount>750 then Pager_PageCount=750
	
	if totalResultsReturned="0" then
	  shoppingproduct="<ul class='ry_b_proudlist ov' style='text-align:center;padding-top:100px'>暂无产品 <a href='javascript:history.go(-1);'>返回上一页</a></ul>"
    else
	  
	  Set item=xml.getElementsByTagName("Item") 
	  For a=0 To (item.Length-1) 
	  '产品ID
	  Set AuctionID=item.Item(a).getElementsByTagName("AuctionID")  
	  set AuctionIDNode = item.Item(a).selectSingleNode("AuctionID")  
	  if Not AuctionIDNode is Nothing Then AuctionID=AuctionID.Item(0).Text else AuctionID=""  
	  '产品名称 
	  Set ItemTitle=item.Item(a).getElementsByTagName("Title") 
	  set TitleNode = item.Item(a).selectSingleNode("Title")  
	  if Not TitleNode is Nothing Then ItemTitle=ItemTitle.Item(0).Text else ItemTitle=""  
	  '产品图片 
	  Set Image=item.Item(a).getElementsByTagName("Image") 
	  set ImageNode = item.Item(a).selectSingleNode("Image")  
	  if Not ImageNode is Nothing Then Image=Image.Item(0).Text else Image=""  
	  '商品价格 
	  Set CurrentPrice=item.Item(a).getElementsByTagName("CurrentPrice") 
	  set CurrentPriceNode = item.Item(a).selectSingleNode("CurrentPrice")  
	  if Not CurrentPriceNode is Nothing Then CurrentPrice=CurrentPrice.Item(0).Text else CurrentPrice="" 
	  '出价次数 
	  Set Bids=item.Item(a).getElementsByTagName("Bids") 
	  set BidsNode = item.Item(a).selectSingleNode("Bids")  
	  if Not BidsNode is Nothing Then Bids=Bids.Item(0).Text else Bids=""  
	  '直购价格 
	  Set BidOrBuy=item.Item(a).getElementsByTagName("BidOrBuy") 
	  set BidOrBuyNode = item.Item(a).selectSingleNode("BidOrBuy")  
	  if Not BidOrBuyNode is Nothing Then BidOrBuy=FormatNumber(cdbl(BidOrBuy.Item(0).Text)*web_rate,2,-1) else BidOrBuy="---"
	  '截至日期 
	  Set EndTime=item.Item(a).getElementsByTagName("EndTime") 
	  set EndTimeNode = item.Item(a).selectSingleNode("EndTime")  
	  if Not EndTimeNode is Nothing Then EndTime=EndTime.Item(0).Text else EndTime=""  
	  '卖家 
	  Set SellerId=item.Item(a).getElementsByTagName("Seller/Id") 
	  set SellerIdNode = item.Item(a).selectSingleNode("Seller/Id")  
	  if Not SellerIdNode is Nothing Then SellerId=SellerId.Item(0).Text else SellerId="" 
	  '新品 
	  Set NewItemIcon=item.Item(a).getElementsByTagName("Option/NewItemIcon") 
	  set NewItemIconNode = item.Item(a).selectSingleNode("Option/NewItemIcon")  
	  if Not NewItemIconNode is Nothing Then NewItemIcon="<div class='new'><span class='icon'>NEW</span></div>" else NewItemIcon=""
	  
	  '判断小时与天
	  endtimex=""
	  if DateDiff("d",now(),dateadd("h",-1,replace(replace(EndTime,"+09:00",""),"T"," ")))<>"0" then
	    endtimex=DateDiff("d",now(),dateadd("h",-1,replace(replace(EndTime,"+09:00",""),"T"," ")))&"天"
	  else
	    endtimex=DateDiff("h",now(),dateadd("h",-1,replace(replace(EndTime,"+09:00",""),"T"," ")))&"小时"
	  end if
	  '判断直购价格
	  BidOrBuyx=""
	  if BidOrBuy<>"" then BidOrBuyx=BidOrBuy&"日元" else BidOrBuyx="---"
	  
	  if a<=6 then shoppingproduct=shoppingproduct+"<tr><td><dl><dt><a href='/auctions/"&AuctionID&".html?s=t'><img src='"&Image&"' width='99'></a></dt><dd><a href='/auctions/"&AuctionID&".html?s=t'>"&ItemTitle&"</a></dd></dl></td><td>"&CurrentPrice&"日元</td><td>"&BidOrBuyx&"</td><td>"&Bids&"</td><td>"&endtimex&"</td></tr>"

	  next 
	end if
	
	
	  
	
	  
	  

	  '分页 
	  UrlView="/auctions/search?s=t&typeid="&CategoryId&"&sort="&sort&"&order="&order&"&style="&style&"&aucminprice="&aucminprice&"&aucmaxprice="&aucmaxprice&"&store="&store&"&item_status="&item_status&"&buynow="&buynow&"&freeshipping="&freeshipping&"&search="&server.urlencode(search)&"&searchkey="&server.urlencode(searchkey)&"&"
	  if CurrentPage<=1 then
	  pageview="<a class='prev_page'> < </a>"
	  else
	  pageview="<a href='"&UrlView&"page="&CurrentPage-1&"'> < </a>"
	  end if
	  if CurrentPage>=7 then
	  pageview=pageview+"<a href='"&UrlView&"page=1'>1</a><a>...</a>"
	  end if
	  if Pager_PageCount<4 then NumPage=Pager_PageCount else NumPage=4
	  for tp = -4 to NumPage
	  if Pager_PageCount>=tp+CurrentPage and tp+CurrentPage=>1  then 
	  if trim(tp+CurrentPage)=CurrentPage or tp=0 then
	  pageview=pageview+"<a class='cur_page'>"&tp+CurrentPage&"</a>"
	  else
	  pageview=pageview+"<a"&pagecss&" href='"&UrlView&"page="&tp+CurrentPage&"'>"&tp+CurrentPage&"</a>"
	  end if
	  end if
	  next
	  if Pager_PageCount>tp+CurrentPage then pageview=pageview+"<a>...</a>"
	  if Pager_PageCount<CurrentPage+1 then
	  pageview=pageview+"<a class='prev_page'> > </a>"
	  else
	  pageview=pageview+"<a href='"&UrlView&"page="&CurrentPage+1&"'> > </a>"
	  end if
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><%=title%></title>
<meta name="keywords" content="<%=title%>" />
<meta name="description" content="<%=title%>" />
<link href="favicon.ico" rel="shortcut icon" type="image/x-icon"/>
<link rel="stylesheet" type="text/css" href="/css/style.css" />
<script type="text/javascript" src="/js/jquery.min.js"></script>
<script type="text/javascript">

$(document).ready(function(){
    jQuery.focusblur = function(focusid) {
		var focusblurid = $(focusid);
		var defval = focusblurid.val();
		
        focusblurid.focus(function(){
			$("#select_key").toggle();
        });
        focusblurid.blur(function(){
			
        });
        
    };
    $.focusblur("#search_2");
	$("#select_key dd").click(function () {
		$('#search_2').val($(this).html());
		$("#select_key").hide();
	});
	
});




$(function (){
	
  $(".main_class_li").hover(function(){
	$(".child_class",this).show();
  });
  $(".main_class_li").mouseleave(function(){
	$(".child_class",this).hide();
  });
  
});
</script>
</head>
<body>

<!--#include file="../../common/topauctions.asp"-->




<div class="clear20"></div>
<!--main-->
<div class="fullwidth bg1">
	<div class="main">
		
        
        <!--#include file="common/left.asp"--> 
        
        	
		<div class="jp_middle">
			<h2 class="jp_h2_2"><a href="/auctions">商品分类</a><%=typelink%></h2>
			<div class="jp_m_box_1">
				<ul class="m_class">
					
                    
                      <%
					  if id="" then id=0
					  set rslist=server.CreateObject("adodb.recordset")
					  sql="select * from auctions where fid="&id&" order by sort asc,id asc"
					  rslist.open sql,conn,1,3
					  if not rslist.eof then
					  do while not rslist.eof
					  response.Write "<li class='bhh' title='"&rslist("title")&"'><a href='/auctions/"&rslist("CategoryId")&"?s=t'>• "&rslist("title")&"</a></li>"
					  rslist.movenext
					  loop
					  rslist.close
					  set rslist=nothing
					  end if		 
					  %> 

				</ul>
			</div>
			<div class="clear10"></div>
			<div class="jp_m_box_1">
				<div class="page_2">
					<span>总共<%=Pager_PageCount%>页第<%=CurrentPage%>页</span>
					<div class="page">
						<%=pageview%>
					</div>
				</div>
				<div class="clear10"></div>
				<table class="stable jp_table_1">
					<tr class="str">
						<th class="th_1">商品名</th>
						<th>现在价格</th>
						<th>即决价格</th>
						<th>入标</th>				
						<th>剩余时间</th>				
					</tr>
					
                    <%=shoppingproduct%>
                    
                    
                    
                  
				</table>
				<div class="clear10"></div>
				<div class="page_2">
					<span>总共<%=Pager_PageCount%>页第<%=CurrentPage%>页</span>
					<div class="page">
						<%=pageview%>
					</div>
				</div>
			</div>
		</div>	
		
        
        
        
        <!--#include file="common/right.asp"--> 
        
        
        	
	</div>
</div>

<div class="clear"></div>



<!--#include file="../../common/footerauctions.asp"-->


</body>
</html>